package com.fudan.biz.visualize.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.fudan.biz.visualize.entity.ChartSetting;
import com.fudan.framework.base.BaseDao;

@Repository
public interface ChartSettingDao extends BaseDao<ChartSetting> {
    ChartSetting findByChartName(@Param("chartName") String chartName);

    @Modifying
    @Query(nativeQuery = true, value = "UPDATE t_chart_setting p SET p.chart_name = :chart_name,p.chart_ds_id = :chart_ds_id," +
            "p.chart_ds_name = :chart_ds_name,p.chart_metrics = :chart_metrics," +
            "p.chart_dimensions = :chart_dimensions,p.chart_querys = :chart_querys, " +
            "p.chart_customs = :chart_customs where p.id = :id")
    Integer updateChartById(@Param("id") Integer id,
                        @Param("chart_name") String chart_name,
                        @Param("chart_ds_id") Integer chart_ds_id,
                        @Param("chart_ds_name") String chart_ds_name,
                        @Param("chart_metrics") String chart_metrics,
                        @Param("chart_dimensions") String chart_dimensions,
                        @Param("chart_querys") String chart_querys,
                        @Param("chart_customs") String chart_customs);

}
